<template>
  <div class="app-warehouse-list">
    <section class="app-main">
      <div class="app-header">
        <span class="type-show">全部仓库</span>
        <!--<mt-button class="btn-filter" type="danger" @click="handleFilter">筛选<span class="iconfont icon-shaixuan"></span></mt-button>-->
        <mt-button class="btn-filter" type="primary" @click="handleAdd">新增<span class="iconfont icon-zengjia"></span></mt-button>
      </div>
      <div class="module-list-none" v-if="warehouseList.length<=0">
        暂无仓库仓位！
      </div>
      <div class="tab-body">

        <mt-cell v-for="(item,index) in warehouseList" :title="item.depot">
          <span class="iconfont icon-bianji" @click="handleEdit(item)"></span>
          <span class="iconfont icon-shanchu" @click="handleRemove(item)"></span>
        </mt-cell>
      </div>
    </section>


  </div>
</template>

<script>
  import { Header,Cell,Toast,MessageBox} from 'mint-ui';
  //  Vue.component(Header.name, Header);
  export default {
    components:{
      Header,
      Cell,
    },
    data () {
      return {
        warehouseList: [],
      }
    },
    mounted(){
      this.getData();
    },
    methods: {

      /** 获取仓库列表 **/
      getData() {
        var params = new URLSearchParams();
        params.append('page','1');
        params.append('rows','50');

        this.$axios({
          method: 'post',
          url:'gp/bu/depot!getDepotList.do',
          data:params
        }).then((res)=>{
          console.log(res,1111)
        this.warehouseList=res.data.rows;
      })
      },

      handleRemove(item){
        MessageBox({
          title: '',
          message: '确认是否删除该仓库?',
          showCancelButton: true
        }).then(action => {
          if(action=='confirm'){



          var params = new URLSearchParams();
          params.append('form.depotId',item.depotId);
          this.$axios({
            method: 'post',
            url:'gp/bu/depot!deleteDepot.do',
            data:params
          }).then((res)=>{
            if(res.data.result==true){
            Toast({
              message: res.data.message,
              position: 'middle',
              duration: 1500
            });
            this.getData()
          }else{
            Toast({
              message: res.data.message,
              position: 'middle',
              duration: 1500
            });
          }
        })

        };
      })
      },
      handleAdd(){
        this.$router.push({path:'/warehouse-add-edit'})
      },
      handleEdit(item){
        this.$router.push({path:'/warehouse-add-edit',query:{id:item.depotId}})
      },
      handleChange(item,index){
        this.currentType=index;
        if(index==0){
          this.getDataCustomer()
        }else{
          this.getDataSupplier()
        }
      },
      handleSelectTest(){
        this.popupTestShow=true
      },
      onTestAddressChange(picker, values){
        this.testAddress=values[0]
      },
      handleSure(){
        this.customerNature=this.testAddress
        this.popupTestShow=false
      },
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style>
  .app-warehouse-list .app-main{
    padding:50px 0 0;
  }
  .app-warehouse-list .app-header{
    background: #fff;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    font-size:15px;
    padding:8px 10px 6px;
    border-bottom:1px solid #ddd;
    overflow: hidden;
    line-height: 30px;
    box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.05);
  }
  .app-warehouse-list .btn-filter{
    /*background: none;*/
    /*color: #666;*/
    float: right;
    padding:8px 16px;
    height:34px;
    font-size: 13px;
    margin-left: 12px;
  }
  .app-warehouse-list .btn-filter .iconfont{
    position: relative;
    font-size: 14px;
    margin-left:3px;
  }
  .app-warehouse-list .tab-body .iconfont{
    padding:0 4px;
  }
  .app-warehouse-list .tab-body .icon-bianji{
    color: #007EE5;
    font-size: 20px;

  }
  .app-warehouse-list .tab-body .icon-shanchu{
    font-size: 26px;

  }
  .app-warehouse-list .tab-body .mint-cell-title{
    padding: 0 6px 0 0;
    line-height: 20px;

  }
  .app-warehouse-list .module-list-none{
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    padding:60px 0 0;
    font-size: 22px;
    color: #999;
    text-align: center;

  }
</style>
